package com.ypinkj.app.utils.resultutils;

/**
 * @author LF
 * @date 2020/9/24 - 14:01
 */
public class ResultUtil {

    public static Result success(Object object) {
        Result result = new Result();
        result.setCode(200);
        result.setMsg(Constant.SUCCESS);
        result.setData(object);
        return result;
    }

    public static Result success() {
        Result result = new Result();
        result.setCode(200);
        result.setMsg(Constant.SUCCESS);
        return result;
    }

    /**
     *
     * 添加错误信息
     *   肖守凯
     * @param msg 错误信息
     * @return
     */
    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(414);
        result.setMsg(msg);
        return result;
    }

    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static Result errorMsg() {
        Result result = new Result();
        result.setMsg(Constant.FAIL);
        return result;
    }

    //后台页面返回page
    public static ResultPage successCount(Object object,Long count) {
        ResultPage result = new ResultPage<>();
        result.setCode(0);
        result.setMsg(Constant.SUCCESS);
        result.setCount(count);
        result.setData(object);
        return result;
    }
}
